const DND = imports.ui.dnd;
const GenericDisplay = imports.ui.genericDisplay;
+const Main = imports.ui.main;
const Workspaces = imports.ui.workspaces;
const ENTERED_MENU_COLOR = new Clutter.Color();
if (this._windows.length == 0)
this.launch();
else {
- /* Pick the first window and activate it, switching to its workspace
- * if necessary. In the future, we want to have a menu dropdown here. */
+ /* Pick the first window and activate it;
+ * In the future, we want to have a menu dropdown here. */
let first = this._windows[0];
- let firstWorkspace = first.get_workspace();
- let currentWorkspaceIndex = Shell.Global.get().screen.get_active_workspace_index();
- let currentWorkspace = Shell.Global.get().screen.get_workspace_by_index(currentWorkspaceIndex);
- let ts = Clutter.get_current_event_time();
- if (currentWorkspace != firstWorkspace)
- firstWorkspace.activate_with_focus(first, ts);
- else
- first.activate(ts);
+ Main.overlay.activateWindow (first, Clutter.get_current_event_time());
}
this.emit('activated');
},
this.show();
},
+ /**
+ * activateWindow:
+ * @metaWindow: A #MetaWindow
+ * @time: Event timestamp integer
+ *
+ * Make the given MetaWindow be the focus window, switching
+ * to the workspace it's on if necessary. This function
+ * should only be used when the overlay is currently active;
+ * outside of that, use the relevant methods on MetaDisplay.
+ */
+ activateWindow: function (metaWindow, time) {
+ this._workspaces.activateWindowFromOverlay(metaWindow, time);
+ this.hide();
+ },
+
//// Private methods ////
// Raises the Dash to the top, so that we can tell if the pointer is above one of its items.
}
},
+ _lookupIndexAndClone: function (metaWindow) {
+ let index, clone;
+ for (let i = 0; i < this._windows.length; i++) {
+ if (this._windows[i].metaWindow == metaWindow) {
+ index = i;
+ clone = this._windows[index];
+ return [index, clone];
+ }
+ }
+ return [-1, null];
+ },
+
+ lookupCloneForMetaWindow: function (metaWindow) {
+ let [index, clone] = this._lookupIndexAndClone (metaWindow);
+ return clone;
+ },
+
_adjustRemoveButton : function() {
this._removeButton.set_scale(1.0 / this.actor.scale_x,
1.0 / this.actor.scale_y);
let win = metaWin.get_compositor_private();
// find the position of the window in our list
- let index = - 1, clone;
- for (let i = 0; i < this._windows.length; i++) {
- if (this._windows[i].metaWindow == metaWin) {
- index = i;
- clone = this._windows[index];
- break;
- }
- }
+ let [index, clone] = this._lookupIndexAndClone (metaWin);
if (index == -1)
return;
},
_onCloneSelected : function (clone, time) {
- let global = Shell.Global.get();
- let activeWorkspace = global.screen.get_active_workspace_index();
-
- if (this.workspaceNum != activeWorkspace) {
- let workspace = global.screen.get_workspace_by_index(this.workspaceNum);
- workspace.activate_with_focus(clone.metaWindow, time);
- } else
- clone.metaWindow.activate(time);
- Main.overlay.hide();
+ Main.overlay.activateWindow(clone.metaWindow, time);
},
_removeSelf : function(actor, event) {
Lang.bind(this, this._activeWorkspaceChanged));
},
+ _lookupCloneForMetaWindow: function (metaWindow) {
+ for (let i = 0; i < this._workspaces.length; i++) {
+ let clone = this._workspaces[i].lookupCloneForMetaWindow(metaWindow);
+ if (clone)
+ return clone;
+ }
+ return null;
+ },
+
+ // Should only be called from active overlay context
+ activateWindowFromOverlay: function (metaWindow, time) {
+ let global = Shell.Global.get();
+ let activeWorkspaceNum = global.screen.get_active_workspace_index();
+ let windowWorkspaceNum = metaWindow.get_workspace().index();
+
+ let clone = this._lookupCloneForMetaWindow (metaWindow);
+ clone.actor.raise_top();
+
+ if (windowWorkspaceNum != activeWorkspaceNum) {
+ let workspace = global.screen.get_workspace_by_index(windowWorkspaceNum);
+ workspace.activate_with_focus(metaWindow, time);
+ } else {
+ metaWindow.activate(time);
+ }
+ },
+
// Updates position of the workspaces display based on the new coordinates.
// Preserves the old value for the coordinate, if the passed value is null.
updatePosition : function(x, y) {